package spring.security.web.handler;

import java.util.HashMap;
import java.util.Map;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import spring.security.exception.UserNullException;

/**
 * 控制器异常处理器
 *
 */
//@ControllerAdvice
public class ControllerExceptionHandler {
	
	@ExceptionHandler(UserNullException.class)
	@ResponseBody
	@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
	public Map<String, Object> handleUserNullException(UserNullException e) {
		Map<String, Object> result = new HashMap<>();
		result.put("id", e.getId());
		result.put("message", e.getMessage());
		return result;
	}
	
}
